/**
 * Created by zhouli on 18/3/30
 * Email li.zhou@huilianyi.com
 */
import config from 'config'
import httpFetch from 'share/httpFetch'
import errorMessage from 'share/errorMessage';

export default {
   //删除图片
  deleteImgId: function (id) {
    return new Promise((resolve, reject) => {
      httpFetch.delete(config.baseUrl + '/api/tenant/delete/logo/'+id)
        .then((res) => {
          resolve(res)
        })
        .catch((err) => {
          errorMessage(err.response);
          reject(err);
        })
    })
  },
  //修改租户自定义图片显示：
  updateTenantInfo: function (data) {
    // data = {
    //      "tenantId": "",
    //      "showCustomLogo": ""
    // }
    return new Promise((resolve, reject) => {
      httpFetch.post(config.baseUrl + '/api/tenant/update/tenantLogo', data)
        .then((res) => {
          resolve(res)
        })
        .catch((err) => {
          errorMessage(err.response);
          reject(err);
        })
    })
  },
  getTenantInfo: function () {
    return new Promise((resolve, reject) => {
      httpFetch.post(config.baseUrl + '/api/company/info/count')
        .then((res) => {
          resolve(res)
        })
        .catch((err) => {
          errorMessage(err.response);
          reject(err);
        })
    })
  },

  //根据租户获取id获取用户协议，租户id可以不传，查当前租户协议
  getUserAgreementByTenantId(id) {
    return new Promise((resolve, reject) => {
      let p;
      if (id) {
        p = httpFetch.get(config.baseUrl + '/api/tenant/protocol/tenant', {tenantId: id})
      } else {
        p = httpFetch.get(config.baseUrl + '/api/tenant/protocol/tenant')
      }
      p.then((res) => {
        resolve(res)
      })
        .catch((err) => {
          errorMessage(err.response);
          reject(err);
        })
    })
  },


}
